<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>调用bootstrap</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="yaf-application.app.html">Yaf_Application::app</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="yaf-application.clearlasterror.html">Yaf_Application::clearLastError</a></div>
 <div class="up"><a href="class.yaf-application.html">Yaf_Application</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="yaf-application.bootstrap" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">Yaf_Application::bootstrap</h1>
  <p class="verinfo">(Yaf &gt;=1.0.0)</p><p class="refpurpose"><span class="refname">Yaf_Application::bootstrap</span> &mdash; <span class="dc-title">调用bootstrap</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-yaf-application.bootstrap-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type"><span class="type void">void</span></span> <span class="methodname"><strong>Yaf_Application::bootstrap</strong></span>
    ([ <span class="methodparam"><span class="type"><a href="class.yaf-bootstrap-abstract.html" class="type Yaf_Bootstrap_Abstract">Yaf_Bootstrap_Abstract</a></span> <code class="parameter">$bootstrap</code></span>
  ] )</div>

  <p class="para rdfs-comment">
    指示Yaf_Application去寻找Bootstrap，并按照声明的顺序，执行所有在Bootstrap类中定义的以_init开头的方法。
    如果没有提供变量bootstrap，Yaf默认会去application.directory中寻找Bootstrap。
  </p>

 </div>


 <div class="refsect1 parameters" id="refsect1-yaf-application.bootstrap-parameters">
  <h3 class="title">参数</h3>
  <dl>

   
    <dt>
<em><code class="parameter">bootstrap</code></em></dt>

    <dd>

     <p class="para">
      A <a href="class.yaf-bootstrap-abstract.html" class="classname">Yaf_Bootstrap_Abstract</a> instance      
     </p>
    </dd>

   
  </dl>

 </div>


 <div class="refsect1 returnvalues" id="refsect1-yaf-application.bootstrap-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   <a href="class.yaf-application.html" class="classname">Yaf_Application</a> instance
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-yaf-application.bootstrap-examples">
  <h3 class="title">范例</h3>
  <div class="example" id="example-4017">
   <p><strong>Example #1 <span class="function"><strong>A Bootstrap()</strong></span>example</strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">/**<br />&nbsp;*&nbsp;This&nbsp;file&nbsp;should&nbsp;be&nbsp;under&nbsp;the&nbsp;APPLICATION_PATH&nbsp;.&nbsp;"/application/"(which&nbsp;was&nbsp;defined&nbsp;in&nbsp;the&nbsp;config&nbsp;passed&nbsp;to&nbsp;Yaf_Application).<br />&nbsp;*&nbsp;and&nbsp;named&nbsp;Bootstrap.php,&nbsp;&nbsp;so&nbsp;the&nbsp;Yaf_Application&nbsp;can&nbsp;find&nbsp;it&nbsp;<br />&nbsp;*/<br /></span><span style="color: #007700">class&nbsp;</span><span style="color: #0000BB">Bootstrap&nbsp;</span><span style="color: #007700">extends&nbsp;</span><span style="color: #0000BB">Yaf_Bootstrap_Abstract&nbsp;</span><span style="color: #007700">{<br />&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;</span><span style="color: #0000BB">_initConfig</span><span style="color: #007700">(</span><span style="color: #0000BB">Yaf_Dispatcher&nbsp;$dispatcher</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"1st&nbsp;called\n"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;</span><span style="color: #0000BB">_initPlugin</span><span style="color: #007700">(</span><span style="color: #0000BB">$dispatcher</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"2nd&nbsp;called\n"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />}<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
   </div>

  </div>
  <div class="example" id="example-4018">
   <p><strong>Example #2 <span class="function"><strong>Yaf_Application::bootstrap()</strong></span>example</strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br />defined</span><span style="color: #007700">(</span><span style="color: #DD0000">'APPLICATION_PATH'</span><span style="color: #007700">)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;APPLICATION_PATH&nbsp;will&nbsp;be&nbsp;used&nbsp;in&nbsp;the&nbsp;ini&nbsp;config&nbsp;file<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">||&nbsp;</span><span style="color: #0000BB">define</span><span style="color: #007700">(</span><span style="color: #DD0000">'APPLICATION_PATH'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">__DIR__</span><span style="color: #007700">));&nbsp;</span><span style="color: #FF8000">//__DIR__&nbsp;was&nbsp;introduced&nbsp;after&nbsp;PHP&nbsp;5.3<br /><br /></span><span style="color: #0000BB">$application&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">Yaf_Application</span><span style="color: #007700">(</span><span style="color: #0000BB">APPLICATION_PATH</span><span style="color: #007700">.</span><span style="color: #DD0000">'/conf/application.ini'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$application</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">bootstrap</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
   </div>

   <div class="example-contents"><p>以上例程的输出类似于：</p></div>
   <div class="example-contents screen">
<div class="cdata"><pre>
1st called
2nd called
</pre></div>
   </div>
  </div>
 </div>


 <div class="refsect1 seealso" id="refsect1-yaf-application.bootstrap-seealso">
  <h3 class="title">参见</h3>
  <ul class="simplelist">
   <li class="member"><a href="class.yaf-bootstrap-abstract.html" class="classname">Yaf_Bootstrap_Abstract</a></li>
  </ul>
 </div>


</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="yaf-application.app.html">Yaf_Application::app</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="yaf-application.clearlasterror.html">Yaf_Application::clearLastError</a></div>
 <div class="up"><a href="class.yaf-application.html">Yaf_Application</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
